//
//  MSDao.h
//  Musou
//
//  Created by luo danal on 4/27/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "FMDatabase.h"

@interface MSDao : NSObject {
    int _rowid;
}

@property (copy,nonatomic) NSString *table;
@property (readonly,nonatomic) FMDatabase *db;

+ (void)initialDBIfNil:(FMDatabase *)db;
+ (FMDatabase *)sharedDB;
+ (BOOL)openDB;
+ (BOOL)closeDB;
+ (id)dao;

- (BOOL)tableExists;
- (BOOL)createTable;

- (id)rowForCondition:(NSString *)condition;
- (BOOL)addOneRow:(id)unit;

- (NSArray *)readListForCondition:(NSString *)condition;
- (BOOL)addList:(NSArray *)unitList;

- (BOOL)removeForCondition:(NSString *)condition;

- (BOOL)update:(NSString *)update forCondition:(NSString *)condition;

//Test methods,curd
- (BOOL)add;
- (BOOL)remove;
- (BOOL)update;
- (void)read;
//- (id)read:(NSString *)condition;
- (NSArray *)readAll;
- (BOOL)removeAll;
- (BOOL)save;
@end
